import {ref, reactive} from 'vue'
import {getMediaTYpe} from "@/api/media/mediatype";

export default function() {
  const mediaTypeList = ref([])
  const mediaTypes = reactive({})
  let createMediaShowTypesKey = ["longvideo", "shortvideo", "imageset", "article", "liveroom"]
  const createMediaShowTypes = reactive({})
  const queryList = reactive({
    page: 1,
    pagesize: 10000,
    iscache: 1
  })
  getMediaTYpe(queryList).then(response => {
    mediaTypeList.value = response.data
    response.data.forEach(type => {
      mediaTypes[type.mediatype] = type.name
      if ( createMediaShowTypesKey.indexOf(type.mediatype) > -1 ){
        createMediaShowTypes[type.mediatype] = type.name
      }
    })
  })
  return {
    mediaTypeList,
    mediaTypes,
    createMediaShowTypes
  }
}
